package com.achartengine.test.activity;

import android.os.Bundle;
import android.view.Gravity;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.achartengine.test.GraphUtils;
import com.achartengine.test.R;
import com.achartengine.test.Test;

import org.achartengine.GraphicalView;

/**
 * Author: dengdayi
 * Date:2016/1/11 16:04
 * Description:饼状图
 */
public class PieChartActivity extends BaseActivity {

    private GraphicalView mGraphicalView;

    @Override
    public void onCreateBase(Bundle savedInstanceState) {
        mTvTitle.setText("饼状图");

        graphicalView();

        if (mFrameLayout.getChildCount() > 0) {
            mFrameLayout.removeAllViews();
        }

        if (mGraphicalView != null) {
            mFrameLayout.addView(mGraphicalView);
        }
    }

    /**
     * 初始化数据
     */
    private void graphicalView() {
        mGraphicalView = (GraphicalView) GraphUtils.getPieChartView(getBaseContext(), Test.getPieList());

        FrameLayout.LayoutParams param3 = new FrameLayout.LayoutParams(100,
                100);
        param3.setMargins(165, 52, 0, 0);
        TextView tvi = new TextView(this);
        tvi.setText("50");
        tvi.setTextSize(30f);
        tvi.setGravity(Gravity.CENTER);
        tvi.setBackgroundResource(R.drawable.bg_renshu);
        // tvi.setBackgroundColor(Color.BLACK);
        tvi.setLayoutParams(param3);
        mFrameLayout.addView(tvi);
    }
}
